﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WP09S03_OfficeTracking.ParentClass
{
    public abstract class ParentController
    {
        
        public string strConnection;

        private Controller.Email email;

        public Exception ErrorException;
        public String ErrorMsg ;

        public ParentController() {
            strConnection = WP09S03_OfficeTracking.Properties.Settings.Default.DBConnectString;
            email = new Controller.Email();

        
        }

        public bool EmailSend(string mailTo, string mailSubject, string mailBody) {
            try
            {

                email.MailTo = mailTo;
                email.MailBody = mailBody; //TEXT MAIL FORMAT,NOT HTML FORMAT
                email.MailSubject = mailSubject;
               return email.Send();
            }
            catch (Exception ex)
            {
                FillError(ex);
                throw ex;
            }

        
        }

        protected void FillError(Exception ex) {
            ErrorException = ex;
            ErrorMsg = ex.Message;
        
        }
    }
}
